package homework4;

public class D3 {

	public static void main(String[] args) {
		int oldArr[] = { 7, 4, 2, 2, 5, 8, 7, 8, 10 };
		int count = 0;
		for (int i = 0; i < oldArr.length - 1; i++) {
			for (int j = i + 1; j < oldArr.length ; j++) {
				if (oldArr[i] == oldArr[j]) {
					oldArr[i] = 0;
					count++;
				}
			}
		}
		int m = oldArr.length - count;
		int[] newArr = new int[m];
		int j = 0;
		for (int i = 0; i < oldArr.length; i++) {
			if (oldArr[i] == 0) {
				continue;
			}
			newArr[j] = oldArr[i];
			j++;
		}
		System.out.print("int newArr[]={");
		for (int i = 0; i < m; i++) {
			System.out.print(newArr[i] + ",");
		}
		System.out.print(newArr[newArr.length - 1] + "}");


	}

}
